<!--
 * 严肃声明：
 * 开源版本请务必保留此注释头信息，若删除我方将保留所有法律责任追究！
 * 可正常分享和学习源码，不得用于违法犯罪活动，违者必究！
 * Copyright (c) 2022 APThink David唐 all rights reserved.
 * 版权所有，侵权必究！
 *
-->
<script lang="ts" setup>
import { appStore } from '@/stores/app'
import log from 'loglevel'

const app = appStore()

function handleOpen(key: string, keyPath: string[]) {
  log.debug(key, keyPath)
  ;[]
}
function handleClose(key: string, keyPath: string[]) {
  log.debug(key, keyPath)
}
</script>

<template>
  <el-scrollbar>
    <!-- <el-menu active-text-color="#ffd04b" background-color="#545c64" text-color="#ffffff" router :collapse="isCollapse" -->
    <el-menu
      class="el-menu-vertical-demo"
      :collapse="app.isMenuCollapse"
      @open="handleOpen"
      @close="handleClose"
      router
    >
      <template v-for="m in app.rolemenus">
        <el-sub-menu v-if="m.children && m.children.length > 0" :index="m.id" :key="m.uid">
          <template #title>
            <el-icon>
              <component :is="m.icon" />
            </el-icon>
            <span>{{ $t('menu.' + m.id) }}</span>
          </template>
          <el-menu-item v-for="c in m.children" :index="c.url" :key="c.id">
            <el-icon>
              <component :is="c.icon" />
            </el-icon>
            <span>{{ $t('menu.' + c.id) }}</span>
          </el-menu-item>
        </el-sub-menu>
        <el-menu-item v-else :index="m.url" :key="'sub-' + m.id">
          <el-icon>
            <component :is="m.icon" />
          </el-icon>
          <template #title>
            <span>{{ $t('menu.' + m.id) }}</span>
          </template>
        </el-menu-item>
      </template>
    </el-menu>
  </el-scrollbar>
</template>

<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
</style>
